﻿@model MembershipUser
@{
    ViewBag.Title = "User";
}
<script type="text/javascript">
    function btn_click(myhref) {
        window.location = myhref
    }

</script>
<h2>
    用户信息</h2>
<table width="200" border="1">
    <tr>
        <td>
            用户名：
        </td>
        <td>@Model.UserName
        </td>
        <td>
            Email:
        </td>
        <td>@Model.Email
        </td>
    </tr>
    <tr>
        <td>
            是否有效：
        </td>
        <td>@Model.IsApproved
        </td>
        <td>
            是否锁定：
        </td>
        <td>@Model.IsLockedOut
        </td>
    </tr>
    <tr>
        <td>
            创建日期 ：
        </td>
        <td>@Model.CreationDate
        </td>
        <td>
            上次登录日期：
        </td>
        <td>@Model.LastLoginDate
        </td>
    </tr>
    <tr>
        <td>
            上次激活日期 ：
        </td>
        <td>@Model.LastActivityDate
        </td>
        <td>
            上次锁定日期：
        </td>
        <td>@Model.LastLockoutDate
        </td>
    </tr>
    <tr>
        <td>
            上次密码修改日期 ：
        </td>
        <td>@Model.LastPasswordChangedDate
        </td>
        <td>
        </td>
        <td>
        </td>
    </tr>
</table>
<div>
    角色：
    <table>
        @foreach (KeyValuePair<string, bool> r in ViewData["InRoles"] as Dictionary<string, bool>) { 
            <tr>
                <td>
                    @r.Key
                </td>
                <td>
                    @if (r.Value) {
                        <input type="button" value="从角色中删除" onclick="javascript:btn_click('@Url.Action("DeleteFromRole", new { userName = Model.UserName, roleName = r.Key })')" />
                    }
                    else {                        
                        <input type="button" value="添加至角色" onclick="javascript:btn_click('@Url.Action("AddToRole", new { userName = Model.UserName, roleName = r.Key })')" />                                                                                                                   
                    }
                </td>
            </tr>                   
        }
    </table>
</div>
<div>
    账户是否被锁定: @Model.IsLockedOut
    @if (@Model.IsLockedOut) { 
        <input type="button" value="解锁" onclick="javascript:btn_click('@Url.Action("UnLock", new { userName = Model.UserName })')" />
    }
    else { 
        <input type="button" value="锁定" onclick="javascript:btn_click('@Url.Action("Lock", new { userName = Model.UserName })')" />
    }
</div>
<div>
    <input type="button" value="删除" onclick="javascript:btn_click('@Url.Action("Delete", new { userName = Model.UserName })')" />
</div>
<div>
    <span>重置密码：</span>
    @using (Html.BeginForm("ResetPassword", "KSPUser")) {
        @Html.Hidden("UserName")
        @Html.Label("请输入新密码")
        @Html.TextBox("Password")
        <input type="submit" value="重置" />
    }
</div>
@Html.ActionLink("用户列表", "List", "KSPUser")
